/*
 * Copyright 2009 BioTeam Inc
 * 
 * Licensed under License GNU LESSER GENERAL PUBLIC LICENSE version 3.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.gnu.org/copyleft/lesser.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package net.bioteam.appweb.gwt.apps.client.Util;

import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.JavaScriptObject;
import com.smartgwt.client.util.JSOHelper;


public class Util 
{

	public native static void redirect(String href) /*-{
    $wnd.location.href=href;
	}-*/;
	
	public native static void open(String href) /*-{
    $wnd.open(href);
	}-*/;
	
	public native static boolean isFirefox()/*-{
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
 		return true;
	} else
	{
		return false;
	}
}-*/;
	
	public native static String showCookie() /*-{
return $doc.cookie;
}-*/;
	

	public static void debugJSObject(JavaScriptObject obj, String name)
	{
		
		GWT.log("-------------------"+name, null);
		String[] properties = JSOHelper.getProperties(obj);
		for (String attr : properties)
		{
			String val = JSOHelper.getAttribute(obj, attr);
			GWT.log(attr + "=" + val, null);
		}
	}
	
	
	public native static String mymd5(String str)
	 /*-{
    return  $wnd.hex_md5(str);
	}-*/;
	
}
